package com.ztt.mapper;

import com.ztt.pojo.entity.zttProduct;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductMapper {
    @Select("select * from products")
    public List<zttProduct> SelectAllProduct();

    @Insert("insert into products (Product_id, Product_name, Product_price, Supplier_id, Product_description, Notes)"
            +"VALUES (#{productID}, #{productName}, #{productPrice}, #{supplierID}, #{productDescription}, #{notes})")
    public void InsertProduct(zttProduct product);


    @Select("select * from products where Product_id = #{productID}")
    public zttProduct getProductById(zttProduct product);


    @Select("select * from products where Product_name = #{productName}")
    public zttProduct getProductByName(zttProduct product);


    @Update("update products "+
            "set Product_id = #{productID} , Product_name = #{productName} , Product_price = #{productPrice} ,"+
            "Supplier_id = #{supplierID} , Product_description = #{productDescription} , Notes = #{notes} "+
            "where Product_id = #{productID}")
    public  void UpdateProduct(zttProduct product);

    @Delete("delete from products where Product_id = #{productID}")
    public void DeleteProduct(zttProduct product);

}
